﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="InfoTypeTreeSelector.ascx.cs"
    Inherits="Admin_Crimson_Controls_InfoTypeTreeSelector" %>
<%@ Register Src="InfoTypeTree.ascx" TagName="InfoTypeTree" TagPrefix="uc1" %>

<script type="text/javascript" language="javascript">
    var canNotSelectedId = "<%=CanNotSelectedId %>";
    $(document).ready(function() {
        $("#<%=thickBoxLinkButton.ClientID %>").css("display", "none");
    })
    function openParentSelected() {
        $("#<%=thickBoxLinkButton.ClientID %>").click();
    }

    function treeViewOnclick(id, text, order) {
        var selectedTypeId = $("#<%=HiddenBoxSelectedParent.ClientID%>").val();
        if (selectedTypeId.length!=0 && order.indexOf(selectedTypeId) != -1) {
            alert(text + "是以选中节点的子，因此不能设定");
            return;
        }
        if (canNotSelectedId.length != 0 && canNotSelectedId.toLowerCase() == selectedTypeId.toLowerCase()) {
            alert("不能把类型'" + text + "'设定在自己之下");
            return;
        }
        $("#<%=showLinkButton.ClientID%>").text(text);
        $("#<%=HiddenBoxSelectedParent.ClientID%>").val(id);
        tb_remove();
    }
</script>

<div>
    <%--
            showLinkButton 用于显示 已经选择的父节点的类别。
            thickBoxLinkButton 用于触发 选择类别的窗体，既被页面内的 HiddenModalContent的内容。
         --%>
    <input type="hidden" runat="server" id="HiddenBoxSelectedParent" />
    <asp:LinkButton ID="showLinkButton" runat="server" Text="根节点" OnClientClick="openParentSelected();return false;"></asp:LinkButton>
    <asp:HyperLink ID="thickBoxLinkButton" runat="server" NavigateUrl="#TB_inline?height=300&width=600&inlineId=hiddenModalContent&modal=true"
        CssClass="thickbox"></asp:HyperLink>
</div>
<div id="hiddenModalContent" style="display: none">
    <asp:UpdatePanel ID="updatePanel2" runat="server">
        <ContentTemplate>
            <uc1:InfoTypeTree ID="selectParentTree" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>
</div>
